define(['app', 'assets/js/bootstrap.bundle.min.js', 'assets/js/bootstrap-select.js'],function(app){return {module: function($scope, $http, eventBusService, httpService, params) {
        $scope.isClassMajorShow = app.parameter.parameter_isClassMajorShow;
        $scope.form.fk_unit='self';
        $scope.form.flag='2';

        //学段列表
        httpService.post(app.urls.stage_selectAll, {}, function (data) {
            if ("0000" === data.code) {
                $scope.stageList = data.data;
            } else {
                alert(data.msg);
            }
        });


        $scope.find = function(){

            httpService.post(app.urls.course_selectByIdPro,{id:params.id},function(data){
                if("0000" === data.code){
                    $scope.form = data.data;
                }else{
                    alert(data.msg);
                }
            });
        }
        $scope.find();



        $scope.saveForm = function(){

            $scope.form.id = params.id
            httpService.post(app.urls.course_update,$scope.form,function(data){
                if("0000" === data.code){

                    $scope.form.fk_course = params.id
                    httpService.post(app.urls.course_other_update,$scope.form,function(data){
                        if("0000" === data.code){
                            eventBusService.publish("content.page.reload",data.data);
                            eventBusService.publish("modal.page.close",{});
                        }else{
                            alert(data.msg);
                        }
                    });

                }else{
                    alert(data.msg);
                }
            });
        }

        $scope.findOffice = function (){
            httpService.post(app.urls.findOffice,{},function(data){
                if("0000" === data.code){
                    $scope.officeList = data.data;
                    $scope.findKclx();
                }else{
                    alert(data.msg);
                }
            });
        }

        $scope.findKclx = function (){
            //查询课程类型
            httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"88111240-d585-448b-a6c7-2b85f7a35b6e"},function(data){
                if("0000" === data.code){
                    $scope.kclxList = data.data;
                    $scope.findKcfl();
                }else{
                    alert(data.msg);
                }
            });
        }

        $scope.findKcfl = function (){
            //查询课程分类
            httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"55cb53b8-878d-4234-985e-3108c9807b82"},function(data){
                if("0000" === data.code){
                    $scope.kcflList = data.data;
                    $scope.findKcLbQg();
                }else{
                    alert(data.msg);
                }
            });
        }

        $scope.findKcLbQg = function (){
            //查询课程类别(全国)
            httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"1594f8de-50b9-4d11-923a-d82498491e8d"},function(data){
                if("0000" === data.code){
                    $scope.kclbQgList = data.data;
                    $scope.findKcxzQg();
                }else{
                    alert(data.msg);
                }
            });
        }

        $scope.findKcxzQg = function (){
            //查询课程性质(全国)
            httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"6c64f32e-020a-4c91-b4eb-193f7128420b"},function(data){
                if("0000" === data.code){
                    $scope.kcxzQgList = data.data;
                    $scope.findKcsxQg();
                }else{
                    alert(data.msg);
                }
            });
        }

        $scope.findKcsxQg = function (){
            //查询课程属性(全国)
            httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"14865274-95ba-4ffe-9a0c-b26efac20fae"},function(data){
                if("0000" === data.code){
                    $scope.kcsxQgList = data.data;
                    $scope.findKcflQg();
                }else{
                    alert(data.msg);
                }
            });
        }

        $scope.findKcflQg = function (){
            //查询课程分类（全国）
            httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"c1c8bc81-49ef-492b-b14a-8d3430361b47"},function(data){
                if("0000" === data.code){
                    $scope.kcflQgList = data.data;
                    $scope.findXklbQg();
                }else{
                    alert(data.msg);
                }
            });
        }

        $scope.findXklbQg = function (){
            //查询课程分类（全国）
            httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"4ccdeb56-9da6-4451-94b8-07cb297c8b4e"},function(data){
                if("0000" === data.code){
                    $scope.xklbQgList = data.data;
                }else{
                    alert(data.msg);
                }
            });
        }

        let init = function () {
            if($scope.isClassMajorShow === "1"){
                $scope.findOffice();
                setTimeout(function (){
                    $('#office_select').selectpicker({
                        'noneSelectedText': '==请选择==',
                        'title': '==请选择==',
                        'liveSearch': true,
                        'noneResultsText': '没有匹配到查询结果：{0}',
                        'header': '选择教研室',
                        'size': 10
                    });
                }, 100);
            }
        }

        init();
    }}});